package com.wzapp.sitposture.usercenter.service;

import com.wzapp.sitposture.common.base.HeaderParam;
import com.wzapp.sitposture.common.error.CustomizedException;
import com.wzapp.sitposture.common.page.PageParam;
import com.wzapp.sitposture.usercenter.entity.User;
import com.wzapp.sitposture.usercenter.entity.UserConfig;
import com.wzapp.sitposture.usercenter.entity.UserIncome;
import com.wzapp.sitposture.usercenter.view.UserDTO;
import org.springframework.data.domain.Page;
import org.springframework.security.core.userdetails.UserDetailsService;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by qianglong on 2018/1/16.
 */
public interface UserService extends UserDetailsService {

    /**
     * 功能: z注册用户<br/>
     *
     * @param user
     * @return User
     * @author ql
     * @create 2018-05-08 10:18
     **/

    User register(User user) throws IOException, CustomizedException;


    /**
     * 功能: 通过账号登录<br/>
     *
     * @param account   手机号码/账号名称
     * @param password 用户密码
     * @param signOs 设备类型
     * @return User
     * @throws CustomizedException
     * @author ql
     * @create 2018-05-08 10:20
     **/
    Map loginByAccount(String account, String password,String signOs) throws CustomizedException;

    /**
     * 功能: 更新账户密码<br/>
     *
     * @param user        用户信息
     * @param newPassword 新密码
     * @return User
     * @author ql
     * @create 2018-05-08 10:20
     **/
    User resetPassword(User user, String newPassword) throws CustomizedException;

    /**
     * 功能: 修改用户信息<br/>
     *
     * @param user 用户信息
     * @param headerParam 请求头信息
     * @return User
     * @throws CustomizedException
     * @author ql
     * @create 2018-05-08 10:21
     **/
    User updateUser(User user,HeaderParam headerParam) throws CustomizedException;

    /**
     * 功能: 通过主键id查询用户信息，不包含统计信息<br/>
     *
     * @param id
     * @return User
     * @author ql
     * @create 2018-05-08 10:22
     **/
    User getUserById(String id);
    /**
     * 功能: 通过邀请码查询用户信息<br/>
     *
     * @param recommendCode
     * @return User
     * @author ql
     * @create 2018-05-08 10:22
     **/
    User findUserByRecommendCode(String recommendCode);

    /**
     * 功能: 通过主键id查询用户信息，包含统计信息<br/>
     *
     * @param id
     * @return User
     * @author ql
     * @create 2018-10-23 17:22
     **/
    User getFullUserById(String id) throws CustomizedException;

    /**
     * 功能: 判断手机号是否注册<br/>
     *
     * @param mobile
     * @return java.lang.Boolean
     * @author ql
     * @create 2018-05-08 10:23
     **/
    Boolean isExists(String mobile);

    /**
     * 通过id获取普通用户信息
     *
     * @param id
     * @return
     */
    UserDTO getSimpleUserById(String id);

    /**
     * 功能: 通过手机号获取用户信息<br/>
     *
     * @param mobile
     * @return User
     * @author ql
     * @create 2018-05-08 10:30
     **/
    User getUserByMobile(String mobile);

    /**
     * 功能: 保存登录日志<br/>
     *
     * @param param
     * @return void
     * @author ql
     * @create 2018-05-08 10:31
     **/
    void publishLoginLogEvent(HashMap<String, Object> param);

    /**
     * 功能: 保存登出日志<br/>
     *
     * @param param
     * @return void
     * @author ql
     * @create 2018-05-08 10:33
     **/
    void publishLogOutLogEvent(HashMap<String, Object> param);

    /**
     * 功能: 获取学习配置<br/>
     *
     * @author qianglong
     * @create 2019/1/9 21:54
     * @param userId
     * @return UserConfig
     **/
    UserConfig findUserConfigById(String userId);
    /**
     * 功能: 修改学习配置<br/>
     *
     * @author qianglong
     * @create 2019/1/9 22:05
     * @param userConfig
     * @return UserConfig
     **/
    UserConfig updateUserConfig(UserConfig userConfig);
    /**
     * 功能: 获取用户收益<br/>
     *
     * @author qianglong
     * @create 2019/1/12 19:38
     * @param userId
     * @return org.springframework.data.domain.Page
     **/
    Page findIncomeByUserId(String userId, PageParam pageParam);

    /**
     * 功能: 查询最近几天新注册用户<br/>
     *
     * @author qianglong
     * @create 2019/2/4 10:46
     * @param freeDays
     * @return java.util.List<com.wzapp.sitposture.usercenter.entity.User>
     **/
    List<User> findNewUserByCreateTime(Integer freeDays);
    
    /**
     * 功能: 保存收益<br/>
     *
     * @author qianglong
     * @create 2019/2/4 11:28
     * @param userIncomeList
     * @return void
     **/
    void saveUserIncome(List<UserIncome> userIncomeList);
    /**
     * 功能: 查询未付费用户<br/>
     *
     * @author qianglong
     * @create 2019/9/30 22:54
     * @param 
     * @return java.util.List<java.lang.String>
     **/
    List<String> findUnpaidUserByCreateTime();

}

